<html>
<head>
<link rel="image_src" href="http://www.coderanch.com/templates/default/images/moosefly.gif" />
<meta property="og:image" content="http://www.coderanch.com/templates/default/images/moosefly.gif"/>
<meta property="og:url" content="http://www.coderanch.com/t/306966/JDBC/java/Execute-sql-file-java"/>
<meta property="og:title" content="Execute .sql file using java [Solved] (JDBC forum at JavaRanch)"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
        <link rel="alternate" type="application/rss+xml" title="JavaRanch: Execute .sql file using java" href="/forums/rss/topicPosts/306966" />
    <meta name="description" content="Hello,   How can I execute .sql(List of .sql files in a resides in local directory)files using java. What I need to do is,   1) Read .sql files one by" />

<style type="text/css">@import url( /templates/default/styles/style.css?1337072116278 );</style>
<style type="text/css">@import url( /templates/default/styles/en_US.css?1337072116278 );</style>

    <style type="text/css">@import url( /templates/default/styles/SyntaxHighlighter.css?1337072116278 );</style>

<title>Execute .sql file using java [Solved] (JDBC forum at JavaRanch)</title>

    <link rel="canonical" href="http://www.coderanch.com/t/306966/JDBC/java/Execute-sql-file-java" />
    <link rel="alternate" media="handheld" href="http://www.coderanch.com/mobile/t/306966/JDBC/java/Execute-sql-file-java?foo=a" />
<link rel="search" type="application/opensearchdescription+xml" href="http://www.coderanch.com/how-to/javaranch-saloon-os.xml" title="JavaRanch Saloon" />
<link rel="search" type="application/opensearchdescription+xml" href="http://www.coderanch.com/how-to/javaranch-faq-os.xml" title="JavaRanch FAQ" />
</head>

<body class="en_US">

    <div align="center" class="shngl">
        <center><table width=55% vspace=30 border=1 cellpadding=15><tr bgcolor=#f0e6d5><td><center><font size="2"> 

<b>File APIs for Java Developers</b><br/>
Manipulate DOC, XLS, PPT, PDF and many others from your application.<br/>
<b><a href="http://www.coderanch.com/forums/forums/banner/redirect/317" target="_blank">http://aspose.com/file-tools</a></b>
</font>
</center></td></tr></table></center>
    </div>

<table width="100%" border="0">
    <tr>
        <td>
            <table cellspacing="0" cellpadding="0" width="100%" border="0">
                <tr>
                    <td align="center">

                            <img src="http://www.coderanch.com/mooseImages/moosefly.gif"  vspace="1" border="0" alt="The moose likes JDBC and the fly likes Execute .sql file using java" title="" />
                    </td>
                    <td class="logo" valign="middle">
                        A friendly place for programming greenhorns!
                    </td>

                    <td width="100%" align="center" valign="middle">
                        <span class="boardtitle">Big Moose Saloon</span>
                        <table cellspacing="0" cellpadding="2" border="0">
                            <tr>
                                <td valign="top" nowrap="nowrap" align="center">&nbsp;
                                    <a id="search" class="mainmenu" href="/forums/search/filters/3"><b>Search</b></a>
                                    | <a id="faq" class="mainmenu nonForumLink" href="http://www.coderanch.com/how-to/java/Java-FAQ"><b>Java FAQ</b></a>
                                    | <a id="latest" class="mainmenu" href="/forums/recentTopics/list">Recent Topics</a>

                                    <br />



                                        <a id="login" class="mainmenu" href="/forums/user/login">Register / Login</a>
                                        <br />

                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <br /><br />
                                        <div class="announcementBar">Win a copy of <a href="http://www.amazon.com/gp/product/007179431X?tag=jranch-20">Web Developer's Cookbook</a> this week in the <a href="http://www.coderanch.com/forums/f-105/PHP">PHP</a> forum!
</div>
                                    </td>
                                </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>


<script type="text/javascript" src="/templates/default/js/userLocalTime.js?1337072116278"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<script type="text/javascript" src="/templates/default/js/jquery.jeditable.pack.js?1337072116278"></script>
<script type="text/javascript" src="/templates/default/js/post_show.js?1337072116278"></script>
<script type="text/javascript" src="/templates/default/js/post.js?1337072116278"></script>
<script type="text/javascript" src="/templates/default/js/pagination.js?1337072116278"></script>
<script type="text/javascript" src="/templates/default/js/wz_tooltip.js"></script>
<script type="text/javascript" src="/templates/default/js/social.js"></script>


<script type="text/javascript">
function showEmail(beforeAt, afterAt)
{
	return beforeAt + "@" + afterAt;
}

function addBookmark(relationType, relationId)
{
	var w = window.open('/forums/bookmarks/insert/' + relationType + '/' + relationId + '', 'bookmark_add', 'width=700, height=200, scrollbars=auto, resizable=true');
	w.focus();
}


    function reportToModerationPrompt(postId) {
        var reason = prompt("Reason for reporting this post:");

        if (reason == null || reason == "") {
            alert("Please specify a reason for reporting this post");
            return false;
        } else {
            var link = document.getElementById("report" + postId);
            link.href += "&reason=" + encodeURIComponent(reason);
        }

        return true;
    }

    var watchImage = "/templates/default/images/watch_topic_start.gif";
    var unwatchImage = "/templates/default/images/stop_watching.gif";
    var watchURL = "/forums/posts/watch/0/306966";
    var unwatchURL = "/forums/posts/unwatch/0/306966";
    var unwatchHandler = function() { turnOn=false; toggleWatch(); return false; };
    var watchHandler = function() { turnOn=true; toggleWatch(); return false; };
    var turnOn, remove;

    function toggleWatch () {
        $.ajax({
            url: turnOn ? watchURL : unwatchURL,
            type: 'POST',
            dataType: 'json',
            success: function (data) {
                //$("#messages").html(data.message);
                if (turnOn) {
                    $(".toggleWatchImage")[0].src = unwatchImage;
                    $(".toggleWatchImage")[1].src = unwatchImage;
                    $(".toggleWatchLink")[0].href = unwatchURL;
                    $(".toggleWatchLink")[1].href = unwatchURL;
                    $(".toggleWatchLink")[0].onclick = unwatchHandler;
                    $(".toggleWatchLink")[1].onclick = unwatchHandler;
                } else {
                    if (remove) {
                        // for unwatching locked topics
                        $(".toggleWatchImage")[0].style.visibility = "hidden";
                        $(".toggleWatchImage")[1].style.visibility = "hidden";
                        $(".toggleWatchLink")[0].href = "#";
                        $(".toggleWatchLink")[1].href = "#";
                        $(".toggleWatchLink")[0].onclick = "return false;";
                        $(".toggleWatchLink")[1].onclick = "return false;";
                    } else {
                        $(".toggleWatchImage")[0].src = watchImage;
                        $(".toggleWatchImage")[1].src = watchImage;
                        $(".toggleWatchLink")[0].href = watchURL;
                        $(".toggleWatchLink")[1].href = watchURL;
                        $(".toggleWatchLink")[0].onclick = watchHandler;
                        $(".toggleWatchLink")[1].onclick = watchHandler;
                    }
                }
            }
        });
    }

    var likeImage = "/templates/default/images/jr.button.plus.1.thumb.gif";
    var unlikeImage = "/templates/default/images/jr.button.minus.1.thumb.gif";

    function toggleLike (postId) {
        var likeURL = "/forums/posts/like/" + postId + "";
        var unlikeURL = "/forums/posts/unlike/" + postId + "";

        var unlikeHandler = function() { turnOn=false; toggleLike(postId); return false; };
        var likeHandler = function() { turnOn=true; toggleLike(postId); return false; };

        $.ajax({
            url: turnOn ? likeURL : unlikeURL,
            type: 'POST',
            dataType: 'json',
            success: function (data) {
                $("#like_message_" + postId).html("<img src='/templates/default/images/thumbs-up.gif'"
                                                    +" title='"+data.message+"'/> "+data.count);
                if (turnOn) {
                    $(".toggleLikeImage_"+postId)[0].src = unlikeImage;
                    $(".toggleLikeLink_"+postId)[0].href = unlikeURL;
                    $(".toggleLikeLink_"+postId)[0].onclick = unlikeHandler;
                    $("#like_message_" + postId).css("visibility", "visible");
                } else {
                    $(".toggleLikeImage_"+postId)[0].src = likeImage;
                    $(".toggleLikeLink_"+postId)[0].href = likeURL;
                    $(".toggleLikeLink_"+postId)[0].onclick = likeHandler;
                    if (data.count == 0)
                        $("#like_message_" + postId).css("visibility", "hidden");
                }
            }
        });
    }

</script>



<table cellspacing="0" cellpadding="10" width="97%" align="center" border="0">
    <tr>
        <td class="bodyline">
        <span class="nav">
            <a class="maintitle" href="http://www.javaranch.com/">JavaRanch</a> &raquo; <a class="maintitle" href="http://www.coderanch.com/forums">Java Forums</a> &raquo;
            <a class="maintitle" href="/forums/c/1/java">Java</a> &raquo;
            <a class="maintitle" href="/forums/f-3/JDBC">JDBC</a>
        </span>



            
<table cellspacing="2" cellpadding="2" width="100%" border="0" class="threadbar">
  <tr>
    <td align="left" valign="middle">
    			<img class="opaque" title="You must login or register" alt="Reply" src="/templates/default/images/reply.gif" width="82px" height="25px" />
			<img class="opaque" title="You must login or register" src="/templates/default/images/bookmark_it.gif" alt='Bookmark "Execute .sql file using java"' width="82" height="25" />
		<img class="opaque" title="You must login or register" 
		  	src="/templates/default/images/watch_topic_start.gif"
			alt='Watch "Execute .sql file using java"' width="82" height="25" />
    </td>
    <td align="right">
      	<img class="opaque" title="You must login or register" alt="New topic" src="/templates/default/images/post.gif" width="82px" height="25px" />
    </td>    
  </tr>
</table>
            <table id="postTable" class="forumline" cellspacing="0" cellpadding="0" width="100%" border="0">
                                <a name="1390636">
                </a><tr>
                    <th class="author" nowrap="nowrap" width="18%">Author</th>
                    <th class="subject">
                        <h1>
                            <span id="topicSubject">Execute .sql file using java</span>
                        </h1>
                    </th>
                </tr>
                                </a>





                    <tr class="firstRowOfPost">



                        <td class="row1 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="1390636"></a>
<span class="authorNameNoLink" title="You must login or register">Sirish Kumar Gongal Reddy</span>


<br />

<span class="gensmall">
	Ranch Hand
	<br />

<br />


	Joined: Oct 25, 2004<br />
	Posts: 109
<br />


</span>

                        </td>

                        <td colspan="1" class="row1" valign="top">
<div class="postinfo row1">
	<div class="date">
		<span class="postdetails">posted <script>"Jun 12, 2008 08:29:00".toLocaleDateTime();</script><noscript><span class="lastPostTime">Jun 12, 2008 02:29:00</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_1390636"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row1 postbody" valign="top" id="post_text_1390636">
                            <span class="postbody">
                                    Hello,<br />  <br /> How can I execute .sql(List of .sql files in a resides in local directory)files using <a href="http://www.javaranch.com" class="faq" title="JavaRanch" target="_new">java</a>. What I need to do is,<br />  <br /> 1) Read .sql files one by one from local directory and execute them in oracle environment using java. If it throughs any execption I need to capture that exception.<br />  <br /> Note: My .sql file will includes lot of database scripts each file will take around 15 to 20 min to execute.<br />  <br /> Many thanks,<br /> Sirish
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row1" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row2 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="1390637"></a>
<span class="authorNameNoLink" title="You must login or register">Jan Cumps</span>


<br />

<span class="gensmall">
	Bartender
	<br />

<br />


	Joined: Dec 20, 2006<br />
	Posts: 2203
<br />


</span>
<br />
<div class="bumperStickers">
    <a class="nonForumLink" href="http://www.coderanch.com/how-to/java/BumperStickers" target="_blank">I like...</a><br />
     	<img src="/images/bumperStickers/16_cpp.gif" alt="C++" title="C++" border="0" />
     	<img src="/images/bumperStickers/16_linux.gif" alt="Linux" title="Linux" border="0" />
     	<img src="/images/bumperStickers/16_netbeans.gif" alt="Netbeans IDE" title="Netbeans IDE" border="0" />
</div>

                        </td>

                        <td colspan="1" class="row2" valign="top">
<div class="postinfo row2">
	<div class="date">
		<span class="postdetails">posted <script>"Jun 12, 2008 11:15:00".toLocaleDateTime();</script><noscript><span class="lastPostTime">Jun 12, 2008 05:15:00</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_1390637"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row2 postbody" valign="top" id="post_text_1390637">
                            <span class="postbody">
                                    Does the file contain data definition (DDL) scripts, like CREATE TABLE or CREATE PROCEDURE, BEGIN .... END?<br /> Or does it only data manipulation (DML) commands, like INSERT INTO, DELETE FROM and UPDATE?
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row2" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row1 userPostInfo" valign="top" align="left" rowspan="3">
                            <a name="1390638"></a>
<span class="authorNameNoLink" title="You must login or register">D Rog</span>


<br />

<span class="gensmall">
	Ranch Hand
	<br />

<br />


	Joined: Feb 07, 2004<br />
	Posts: 469
<br />


</span>

                        </td>

                        <td colspan="1" class="row1" valign="top">
<div class="postinfo row1">
	<div class="date">
		<span class="postdetails">posted <script>"Jun 12, 2008 19:56:00".toLocaleDateTime();</script><noscript><span class="lastPostTime">Jun 12, 2008 13:56:00</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_1390638"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row1 postbody" valign="top" id="post_text_1390638">
                            <span class="postbody">
                                    I have a small project wich is capable to execute SQL script files with different statements including view, sp creations. Merhaps you find it useful<br />  <br /> <a href="http://sourceforge.net/project/platformdownload.php?group_id=212014" target="_blank" >http://sourceforge.net/project/platformdownload.php?group_id=212014</a>
                            </span>


                        </td>
                    </tr>

                        <tr>
                            <td colspan="2" class="row1" width="100%" height="28">
                            <br />
                                <hr/>
                                <span class="userSignature">Get power of your iPod with <a class="snap_shots" href="http://mediachest.sourceforge.net/" target="_new" rel="nofollow">MediaChest</a> | Minimal J2EE container is <a class="snap_shots" href="http://tjws.sourceforge.net/" target="_new" rel="nofollow">here</a> | <a class="snap_shots" href="http://7bee.j2ee.us/blog/2008/01/11/1200098880000.html" target="_new" rel="nofollow">Light weight full J2EE stack</a> | <a class="snap_shots" href="http://7bee.j2ee.us/blog" target="_new" rel="nofollow">My blog</a> | Co-author of "Windows programming in Turbo Pascal"</span>
                            </td>
                        </tr>
                    <tr>
                        <td class="spacerow row1" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row2 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="1390639"></a>
<span class="authorNameNoLink" title="You must login or register">Sirish Kumar Gongal Reddy</span>


<br />

<span class="gensmall">
	Ranch Hand
	<br />

<br />


	Joined: Oct 25, 2004<br />
	Posts: 109
<br />


</span>

                        </td>

                        <td colspan="1" class="row2" valign="top">
<div class="postinfo row2">
	<div class="date">
		<span class="postdetails">posted <script>"Jun 12, 2008 22:56:00".toLocaleDateTime();</script><noscript><span class="lastPostTime">Jun 12, 2008 16:56:00</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_1390639"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row2 postbody" valign="top" id="post_text_1390639">
                            <span class="postbody">
                                    Hello,<br />  <br /> Thanks for replies. Yes my scripts only includes DML operations like drop the tables and load tables with default tables and check all tables are created properly or not like stuff. No procedure or functions. <br />  <br /> My .sql scripts do kind of security check for database before deploying my actual application.<br />  <br /> Many thanks,<br /> Sirish
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row2" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row1 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="1390640"></a>
<span class="authorNameNoLink" title="You must login or register">Sirish Kumar Gongal Reddy</span>


<br />

<span class="gensmall">
	Ranch Hand
	<br />

<br />


	Joined: Oct 25, 2004<br />
	Posts: 109
<br />


</span>

                        </td>

                        <td colspan="1" class="row1" valign="top">
<div class="postinfo row1">
	<div class="date">
		<span class="postdetails">posted <script>"Jun 13, 2008 02:51:00".toLocaleDateTime();</script><noscript><span class="lastPostTime">Jun 12, 2008 20:51:00</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_1390640"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row1 postbody" valign="top" id="post_text_1390640">
                            <span class="postbody">
                                    Hello,<br />  <br /> I got the solution. Here is the method I wrote and I found some inputs from sun forums. Thanks Again!<br />  <br /> public boolean executeDBScripts(<a href="http://www.coderanch.com/t/410859/java/java/String-StringBuffer-StringBuilder-Performance" class="api" title="String vs. StringBuilder/StringBuffer" target="_new">String</a> aSQLScriptFilePath, Statement stmt) throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html" class="api" title="Java API" target="_new">IOException</a>,<a href="http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html" class="api" title="Java API" target="_new">SQLException</a> {<br /> boolean isScriptExecuted = false;<br /> try {<br /> <a href="http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html" class="api" title="Java API" target="_new">BufferedReader</a> in = new <a href="http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html" class="api" title="Java API" target="_new">BufferedReader</a>(new <a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileReader.html" class="api" title="Java API" target="_new">FileReader</a>(aSQLScriptFilePath));<br /> String str;<br /> <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html" class="api" title="Java API" target="_new">StringBuffer</a> sb = new <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html" class="api" title="Java API" target="_new">StringBuffer</a>();<br /> while ((str = in.readLine()) != null) {<br /> sb.append(str + "\n ");<br /> }<br /> in.close();<br /> stmt.executeUpdate(sb.toString());<br /> isScriptExecuted = true;<br /> } catch (Exception e) {<br /> System.err.println("Failed to Execute" + aSQLScriptFilePath +". The error is"+ e.getMessage());<br /> } <br /> return isScriptExecuted;<br /> }
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row1" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row2 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="2176706"></a>
<span class="authorNameNoLink" title="You must login or register">Theo Arril</span>


<br />

<span class="gensmall">
	Greenhorn
	<br />

<br />


	Joined: Feb 25, 2010<br />
	Posts: 2
<br />


</span>

                        </td>

                        <td colspan="1" class="row2" valign="top">
<div class="postinfo row2">
	<div class="date">
		<span class="postdetails">posted <script>"Feb 25, 2010 16:36:47".toLocaleDateTime();</script><noscript><span class="lastPostTime">Feb 25, 2010 09:36:47</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2176706"
					class="likesDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
						title='1 person found this post helpful.'
				/>
				1        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row2 postbody" valign="top" id="post_text_2176706">
                            <span class="postbody">
                                    Hello,<br /> I tried your solution but I got many errors.<br /> <br /> First of all you must know that there's no direct way to execute an SQL script file directly through <a href="http://www.coderanch.com/forums/f-3/JDBC" class="api" title="the JavaRanch JDBC forum" target="_new">JDBC</a>  <img src="http://www.coderanch.com/images/smilies/c30b4198e0907b23b8246bdd52aa1c3c.gif" /><br /> You can't load a SQL file into <u>one</u> statement and excute it.<br /> <br /> You will have to write your own (very little) parser to split the script in <b>individual statements</b> and <b>execute them one by one</b>.<br /> Splitting in Statements is the biggest challenge here ; so here is my solution :<br /> <br /> <br /> <font color='blue'><span style="font-size: 18px; line-height: normal;">DatabaseReseter.java</span></font><br /> <textarea name="code" class="java" cols="60" rows="10">
import java.io.BufferedReader;

import java.io.File;
import java.io.FileReader;

import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;

public class Database  {

    private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";

    static
    {
        try
        {
            Class.forName(DRIVER_NAME).newInstance();
            System.out.println("*** Driver loaded");
        }
        catch(Exception e)
        {
            System.out.println("*** Error : "+e.toString());
            System.out.println("*** ");
            System.out.println("*** Error : ");
            e.printStackTrace();
        }

    }

    private static final String URL = "jdbc:mysql://localhost/mydatabase";
    private static final String USER = "root";
    private static final String PASSWORD = "password";
    private static String INSTRUCTIONS = new String();

    public static Connection getConnection() throws SQLException
    {
        return DriverManager.getConnection(URL, USER, PASSWORD);
    }

    public static void resetDatabase() throws SQLException
    {
        String s            = new String();
        StringBuffer sb = new StringBuffer();

        try
        {
            FileReader fr = new FileReader(new File("mySQLFile.sql"));
            // be sure to not have line starting with "--" or "/*" or any other non aplhabetical character

            BufferedReader br = new BufferedReader(fr);

            while((s = br.readLine()) != null)
            {
                sb.append(s);
            }
            br.close();

            // here is our splitter ! We use ";" as a delimiter for each request
            // then we are sure to have well formed statements
            String[] inst = sb.toString().split(";");

            Connection c = Database.getConnection();
            Statement st = c.createStatement();

            for(int i = 0; i&lt;inst.length; i++)
            {
                // we ensure that there is no spaces before or after the request string
                // in order to not execute empty statements
                if(!inst[i].trim().equals(""))
                {
                    st.executeUpdate(inst[i]);
                    System.out.println("&gt;&gt;"+inst[i]);
                }
            }
  
        }
        catch(Exception e)
        {
            System.out.println("*** Error : "+e.toString());
            System.out.println("*** ");
            System.out.println("*** Error : ");
            e.printStackTrace();
            System.out.println("################################################");
            System.out.println(sb.toString());
        }

    }
</textarea><br /> <br /> That's my solution, so try and tell me about it !!  <img src="http://www.coderanch.com/images/smilies/jr-beerchug.gif" border="0"> 
                            </span>



                                <p><span class="edited">This message was edited 1 time. Last update was at <script>"Feb 25, 2010 16:37:29".toLocaleDateTime();</script><noscript>Feb 25, 2010 09:37:29</noscript> by Theo Arril</span></p>
                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row2" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row1 userPostInfo" valign="top" align="left" rowspan="3">
                            <a name="2176886"></a>
<span class="authorNameNoLink" title="You must login or register">Jeanne Boyarsky</span>


<br />

<span class="gensmall">
	internet detective
	<br />
	Marshal
	<br />

<br />


	Joined: May 26, 2003<br />
	Posts: 23575
<br />


</span>
  <iframe src="/forums/bbf/belt/boyarsky" frameBorder="0" height=30 width=40 scrolling="no"></iframe>
<br />
<div class="bumperStickers">
    <a class="nonForumLink" href="http://www.coderanch.com/how-to/java/BumperStickers" target="_blank">I like...</a><br />
     	<img src="/images/bumperStickers/16_eclipse.gif" alt="Eclipse IDE" title="Eclipse IDE" border="0" />
     	<img src="/images/bumperStickers/16_java.gif" alt="Java" title="Java" border="0" />
     	<img src="/images/bumperStickers/16_vi.gif" alt="VI Editor" title="VI Editor" border="0" />
</div>

                        </td>

                        <td colspan="1" class="row1" valign="top">
<div class="postinfo row1">
	<div class="date">
		<span class="postdetails">posted <script>"Feb 25, 2010 22:50:46".toLocaleDateTime();</script><noscript><span class="lastPostTime">Feb 25, 2010 15:50:46</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2176886"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row1 postbody" valign="top" id="post_text_2176886">
                            <span class="postbody">
                                    <blockquote>
			<div>
				<cite>Theo Arril wrote:</cite>First of all you must know that there's no direct way to execute an SQL script file directly through JDBC  <img src="http://www.coderanch.com/images/smilies/c30b4198e0907b23b8246bdd52aa1c3c.gif" /><br /> You can't load a SQL file into <u>one</u> statement and excute it. </div>
		</blockquote><br /> Through JDBC, no.  But you can run it as an Oracle command line through Runtime.exec
                            </span>


                        </td>
                    </tr>

                        <tr>
                            <td colspan="2" class="row1" width="100%" height="28">
                            <br />
                                <hr/>
                                <span class="userSignature">[<a class="snap_shots" href="http://www.selikoff.net" target="_new" >Blog</a>] [<a class="snap_shots" href="http://faq.javaranch.com/java/JavaRanchFaq" target="_new" >JavaRanch FAQ</a>] [<a class="snap_shots" href="http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch" target="_new" >How To Ask Questions The Smart Way</a>] [<a class="snap_shots" href="http://faq.javaranch.com/java/BookPromotions" target="_new" >Book Promos</a>]<br /> Certs: <a class="snap_shots" href="http://www.selikoff.net/2010/07/16/jeannes-scea-5-part-1-experiences/" target="_new" >SCEA Part 1</a>, <a class="snap_shots" href="http://www.selikoff.net/2010/11/17/jeanne%E2%80%99s-sceaocmjca-5-part-23-experiences/" target="_new" >Part 2 & 3</a> &  <a class="snap_shots" href="http://www.selikoff.net/2010/08/20/jeannes-core-spring-3-certification-experiences" target="_new" >Core Spring 3</a></span>
                            </td>
                        </tr>
                    <tr>
                        <td class="spacerow row1" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row2 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="2176898"></a>
<span class="authorNameNoLink" title="You must login or register">Theo Arril</span>


<br />

<span class="gensmall">
	Greenhorn
	<br />

<br />


	Joined: Feb 25, 2010<br />
	Posts: 2
<br />


</span>

                        </td>

                        <td colspan="1" class="row2" valign="top">
<div class="postinfo row2">
	<div class="date">
		<span class="postdetails">posted <script>"Feb 25, 2010 23:27:19".toLocaleDateTime();</script><noscript><span class="lastPostTime">Feb 25, 2010 16:27:19</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2176898"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row2 postbody" valign="top" id="post_text_2176898">
                            <span class="postbody">
                                    how about PostgreSQL ?
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row2" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row1 userPostInfo" valign="top" align="left" rowspan="3">
                            <a name="2186539"></a>
<span class="authorNameNoLink" title="You must login or register">Harsha Muthy</span>


<br />

<span class="gensmall">
	Greenhorn
	<br />

<br />


	Joined: Mar 10, 2010<br />
	Posts: 1
<br />


</span>

                        </td>

                        <td colspan="1" class="row1" valign="top">
<div class="postinfo row1">
	<div class="date">
		<span class="postdetails">posted <script>"Mar 10, 2010 20:28:32".toLocaleDateTime();</script><noscript><span class="lastPostTime">Mar 10, 2010 13:28:32</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2186539"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row1 postbody" valign="top" id="post_text_2186539">
                            <span class="postbody">
                                    <font color='green'>@Theo Arril -  Awesome code. I tried this and it works for me. Thanks a ton, you really saved me.</font>  <img src="http://www.coderanch.com/images/smilies/jr-icon_jumping.gif" border="0">
                            </span>



                                <p><span class="edited">This message was edited 1 time. Last update was at <script>"Mar 10, 2010 20:29:37".toLocaleDateTime();</script><noscript>Mar 10, 2010 13:29:37</noscript> by Harsha Muthy</span></p>
                        </td>
                    </tr>

                        <tr>
                            <td colspan="2" class="row1" width="100%" height="28">
                            <br />
                                <hr/>
                                <span class="userSignature">- Harsha</span>
                            </td>
                        </tr>
                    <tr>
                        <td class="spacerow row1" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row2 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="2199170"></a>
<span class="authorNameNoLink" title="You must login or register">Tom Enders</span>


<br />

<span class="gensmall">
	Greenhorn
	<br />

<br />


	Joined: Mar 27, 2010<br />
	Posts: 4
<br />


</span>

                        </td>

                        <td colspan="1" class="row2" valign="top">
<div class="postinfo row2">
	<div class="date">
		<span class="postdetails">posted <script>"Mar 27, 2010 14:46:52".toLocaleDateTime();</script><noscript><span class="lastPostTime">Mar 27, 2010 08:46:52</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2199170"
					class="likesDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
						title='1 person found this post helpful.'
				/>
				1        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row2 postbody" valign="top" id="post_text_2199170">
                            <span class="postbody">
                                    <blockquote>
			<div>
				<cite>Theo Arril wrote:</cite>Hello,<br /> I tried your solution but I got many errors.<br /> <br /> First of all you must know that there's no direct way to execute an SQL script file directly through JDBC  <img src="http://www.coderanch.com/images/smilies/c30b4198e0907b23b8246bdd52aa1c3c.gif" /><br /> You can't load a SQL file into <u>one</u> statement and excute it.<br /> <br /> You will have to write your own (very little) parser to split the script in <b>individual statements</b> and <b>execute them one by one</b>.<br /> Splitting in Statements is the biggest challenge here ; so here is my solution :<br /> <br /> <br /> <br /> That's my solution, so try and tell me about it !!  <img src="http://www.coderanch.com/images/smilies/jr-beerchug.gif" border="0"> </div>
		</blockquote><br /> <br /> Your parser does not work on a file that contains transactions. I found this when I tried to run it on a file to create a database which contained triggers. So, I rewrote the parser. Here is the code, the comments should be enough to explain it. So use this just replace the split line in Theo's solution with the following code.<br /> <textarea name="code" class="java" cols="60" rows="10">
            //begin the sql file parser to separate the sql commands into
            //separate array entries. This parser requires that your
            //sql statements be typed in uppercase because that is the 
            //convention of the author.

            //Step 1: Assume that every SQL statement ends with a semi colon
            String[] stmts = sb.toString().split(";");

            //Step 2: Put Transactions back into a single statement.
            for(int i=0;i&lt;stmts.length;i++){
                //if the current statement starts a transaction
                if(stmts[i].contains("BEGIN")){
                    int tInt = i;
                    //find the end of the transaction or the end of the file
                    //whichever comes first
                    while(tInt&lt;stmts.length && !stmts[tInt].contains("END")) {
                        tInt++;
                    } //end while

                    //add a semicolon to the first sql entry in the transaction
                    //which will be in the same array entry as the BEGIN
                    //statement
                    stmts[i] += ";";

                    //loop through the remaining transaction and place them
                    //into the transaction start entry appending semicolons
                    //at the end of each statement
                    for(int j = (i+1); j&lt; tInt; j++) {
                        stmts[i] += "\n" + stmts[j] + ";";
                        //blank out the current transaction entry so that the
                        //executer skips it
                        stmts[j] = " ";
                    } //end for

                    //and the end statement to the end of the transaction
                    stmts[i] += "\nEND";

                    //remove the END transaction from the statement it is
                    //currently embedded in
                    String tStr[] = stmts[tInt].split("END");
                    stmts[tInt] = tStr[1];
                    //skip the statements blanked out earlier, actually pointing
                    //to the last transaction entry so that the for statement
                    //points to the first statement after the transaction
                    i = tInt - 1;
                } //end if

            } //end for

            //end sql file parsers
</textarea>
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row2" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row1 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="2610156"></a>
<span class="authorNameNoLink" title="You must login or register">neo Infinite</span>


<br />

<span class="gensmall">
	Greenhorn
	<br />

<br />


	Joined: Apr 16, 2012<br />
	Posts: 1
<br />


</span>

                        </td>

                        <td colspan="1" class="row1" valign="top">
<div class="postinfo row1">
	<div class="date">
		<span class="postdetails">posted <script>"Apr 16, 2012 10:02:21".toLocaleDateTime();</script><noscript><span class="lastPostTime">Apr 16, 2012 04:02:21</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2610156"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row1 postbody" valign="top" id="post_text_2610156">
                            <span class="postbody">
                                    <blockquote>
			<div>
				<cite>Theo Arril wrote:</cite>Hello,<br /> I tried your solution but I got many errors.<br /> <br /> First of all you must know that there's no direct way to execute an SQL script file directly through JDBC  <img src="http://www.coderanch.com/images/smilies/c30b4198e0907b23b8246bdd52aa1c3c.gif" /><br /> You can't load a SQL file into <u>one</u> statement and excute it.<br /> <br /> You will have to write your own (very little) parser to split the script in <b>individual statements</b> and <b>execute them one by one</b>.<br /> Splitting in Statements is the biggest challenge here ; so here is my solution :<br /> <br /> <br /> <font color='blue'><span style="font-size: 18px; line-height: normal;">DatabaseReseter.java</span></font><br /> <textarea name="code" class="java" cols="60" rows="10">
import java.io.BufferedReader;

import java.io.File;
import java.io.FileReader;

import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;

public class Database  {

    private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";

    static
    {
        try
        {
            Class.forName(DRIVER_NAME).newInstance();
            System.out.println("*** Driver loaded");
        }
        catch(Exception e)
        {
            System.out.println("*** Error : "+e.toString());
            System.out.println("*** ");
            System.out.println("*** Error : ");
            e.printStackTrace();
        }

    }

    private static final String URL = "jdbc:mysql://localhost/mydatabase";
    private static final String USER = "root";
    private static final String PASSWORD = "password";
    private static String INSTRUCTIONS = new String();

    public static Connection getConnection() throws SQLException
    {
        return DriverManager.getConnection(URL, USER, PASSWORD);
    }

    public static void resetDatabase() throws SQLException
    {
        String s            = new String();
        StringBuffer sb = new StringBuffer();

        try
        {
            FileReader fr = new FileReader(new File("mySQLFile.sql"));
            // be sure to not have line starting with "--" or "/*" or any other non aplhabetical character

            BufferedReader br = new BufferedReader(fr);

            while((s = br.readLine()) != null)
            {
                sb.append(s);
            }
            br.close();

            // here is our splitter ! We use ";" as a delimiter for each request
            // then we are sure to have well formed statements
            String[] inst = sb.toString().split(";");

            Connection c = Database.getConnection();
            Statement st = c.createStatement();

            for(int i = 0; i&lt;inst.length; i++)
            {
                // we ensure that there is no spaces before or after the request string
                // in order to not execute empty statements
                if(!inst[i].trim().equals(""))
                {
                    st.executeUpdate(inst[i]);
                    System.out.println("&gt;&gt;"+inst[i]);
                }
            }
  
        }
        catch(Exception e)
        {
            System.out.println("*** Error : "+e.toString());
            System.out.println("*** ");
            System.out.println("*** Error : ");
            e.printStackTrace();
            System.out.println("################################################");
            System.out.println(sb.toString());
        }

    }
</textarea><br /> <br /> That's my solution, so try and tell me about it !!  <img src="http://www.coderanch.com/images/smilies/jr-beerchug.gif" border="0"> </div>
		</blockquote><br /> <br /> <b>Thanks </b>for the great solution first!  <img src="http://www.coderanch.com/images/smilies/e8a506dc4ad763aca51bec4ca7dc8560.gif" /> <br /> I tried using it, but the problem is that my .sql file has INSERT queries for multiple tables. And so I am setting the values for each table's primary keys<br /> however it gives an error. Could you please suggest something here?<br /> <br /> Please see the stack trace below:<br /> <font color='red'>"*** Driver loaded<br /> *** Error : com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'PRIMARY'<br /> *** <br /> *** Error : <br /> <b>com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'PRIMARY'################################################</b><br /> <br /> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br /> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)<br /> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)<br /> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:525)<br /> 	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)<br /> 	at com.mysql.jdbc.Util.getInstance(Util.java:386)<br /> 	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)<br /> 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)<br /> 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)<br /> 	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)<br /> 	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)<br /> 	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)<br /> 	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1749)<br /> 	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1666)<br /> 	at com.eurexchange.clear.tradeinquiry.service.TradeInquirySampleDatabase.setUpDatabase(TradeInquirySampleDatabase.java:71)<br /> 	at com.eurexchange.clear.tradeinquiry.service.TradeInquiryServiceImplTest.before(TradeInquiryServiceImplTest.java:39)<br /> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br /> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br /> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br /> 	at java.lang.reflect.Method.invoke(Method.java:601)<br /> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)<br /> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)<br /> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)<br /> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)<br /> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)<br /> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)<br /> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)<br /> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)<br /> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)<br /> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)<br /> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)<br /> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)<br /> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)<br /> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)<br /> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)<br /> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)<br /> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)<br /> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)<br /> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)<br /> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)"</font>
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row1" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>




                    <tr class="firstRowOfPost">



                        <td class="row2 userPostInfo" valign="top" align="left" rowspan="2">
                            <a name="2610177"></a>
<span class="authorNameNoLink" title="You must login or register">Wendy Gibbons</span>


<br />

<span class="gensmall">
	Bartender
	<br />

<br />


	Joined: Oct 21, 2008<br />
	Posts: 698
<br />


</span>
<br />
<div class="bumperStickers">
    <a class="nonForumLink" href="http://www.coderanch.com/how-to/java/BumperStickers" target="_blank">I like...</a><br />
     	<img src="/images/bumperStickers/16_eclipse.gif" alt="Eclipse IDE" title="Eclipse IDE" border="0" />
     	<img src="/images/bumperStickers/16_oracle.gif" alt="Oracle" title="Oracle" border="0" />
     	<img src="/images/bumperStickers/16_vi.gif" alt="VI Editor" title="VI Editor" border="0" />
</div>

                        </td>

                        <td colspan="1" class="row2" valign="top">
<div class="postinfo row2">
	<div class="date">
		<span class="postdetails">posted <script>"Apr 16, 2012 10:29:44".toLocaleDateTime();</script><noscript><span class="lastPostTime">Apr 16, 2012 04:29:44</span></noscript></span>                

		<img class="opaque" alt="private message" title="You must login or register" src="/templates/default/images/icon_pm.gif" width="59px" height="18px" />


    </div>
	<div class="action">
			<div id="like_message_2610177"
					class="likesHiddenDiv"
			>
				<img src="/templates/default/images/thumbs-up.gif"
				/>
				0        
			</div>
			<img class="opaque" alt="Quote" title="You must login or register" src="/templates/default/images/icon_quote.gif" width="59" height="18px" />
	</div>
</div>
                        </td>
                    </tr>

                    <tr class="messageRow">

                        <td class="row2 postbody" valign="top" id="post_text_2610177">
                            <span class="postbody">
                                    Welcome to the ranch Neo<br /> I suspect this means your script is wrong, do you understand the error you are getting?
                            </span>


                        </td>
                    </tr>

                    <tr>
                        <td class="spacerow row2" colspan="2" height="1"><img src="/templates/default/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
            <tr>
            <td width="18%" bgcolor="#DEC7A4"><img src="/images/bunkhouse_smoke.gif"/></td>
            <td width="82%" align="left" valign="top"  bgcolor="#DEC7A4">
                &nbsp;<BR>
                    <div align="left" class="shngl">
                        <script type="text/javascript"><!--
google_ad_client = "pub-4768842087373098";
/* crf/s1/ss */
google_ad_slot = "3954018497";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

                    </div>
                &nbsp;<BR>
                </td>
                </tr>
                <tr class="postbody" align="left">
                    <td colspan="2">
                    subject: Execute .sql file using java
                    </td>
                </tr>

                <tr align="center">
                    <td class="catbottom" colspan="2" height="28">
                        <table cellspacing="0" cellpadding="0" border="0">
                            <tr>
                                <td align="center"><span class="gensmall">&nbsp;</span></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
             
            
            <table width="100%" align="center">


            </table>

        </td>
    </tr>
</table>

<table class="highlights" align="center">
<tr><th colspan="2">Threads others viewed</th></tr>
<tr>
  <tr><td class="row1 gen"><a href="/t/328952/java/java/JVM-jar"> 
  JVM for jar</a></td></tr>
  <tr><td class="row1 gen"><a href="/t/305079/JDBC/java/Running-sql-files-against-database"> 
  Running the sql files against database</a></td></tr>
  <tr><td class="row1 gen"><a href="/t/240531/java-programmer-SCJP/certification/Try-MockTest"> 
  Try my MockTest</a></td></tr>
  <tr><td class="row1 gen"><a href="/t/110549/Linux-UNIX/Find-Num-files-FTP-Server"> 
  Find Num of files in FTP Server directory </a></td></tr>
  <tr><td class="row1 gen"><a href="/t/532684/java/java/PATH-variable-javac-file-not"> 
  Problem with PATH variable: javac: file not found error</a></td></tr>
</tr>
</table>

<a name="quick"></a>

<script type="text/javascript">
$(document).ready(function() {
    limitURLSize();
});
</script>

		</td>
	</tr>
</table>
<div class="gensmall center">
<script>
document.write("All times above are in your local time zone & format.");
document.write("The current ranch time (not your local time) is ");
document.write("May 15, 2012 10:35:08".bold() + ".");
</script><noscript>All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter</noscript>
</div>

	<div align="center" class="shngl">
		<a href="/forums/banner/redirect/313" target="_blank"><img src="http://www.coderanch.com/intellij.png"  border="0" alt="IntelliJ Java IDE"  /></a>
	</div>

<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ?  "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
if (typeof _gat !== "undefined") {
	var pageTracker = _gat._getTracker("UA-2371260-2");
	pageTracker._trackPageview();

	dt = new Date();
	pageTracker._setVar("hour: " + dt.getHours());
}
</script>

<br />
<div class="float-divider"></div>
<div id="footer">
 <div class="footerLinksDiv center">
	<a class="nonForumLink" href="http://www.coderanch.com/how-to/code/ContactUs">Contact Us</a>
	| Powered by <a href="http://www.jforum.net/" target="_blank">JForum</a>
	| <span class="copyrightOwner">Copyright &copy; 1998-2012 <a href="http://www.javaranch.com/paul-wheaton.jsp">Paul Wheaton</a></span>
 </div>
</div>
<div class="float-divider"></div>
<!-- SyntaxHighlighter 1.5.1 -->
<script type="text/javascript" src="/templates/default/js/shCore.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushCss.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushJava.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushCpp.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushJScript.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushPython.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushRuby.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushSql.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushXml.js"></script>
<script type="text/javascript" src="/templates/default/js/shBrushPlain.js"></script>
                                                

<script type="text/javascript">
<!--
dp.sh.ClipboardSwf = '/templates/default/js/clipboard.swf';
dp.sh.HighlightAll('code');
-->
</script>

<div align="center" class="shngl">
	<table>
<tr>

<td>
            <script type="text/javascript"><!--
            google_ad_client = "pub-4768842087373098";
            /* 125x125, created 11/20/09 */
            google_ad_slot = "6061358209";
            google_ad_width = 125;
            google_ad_height = 125;
            //-->
            </script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
            </script>

</td>
<td>
<div style="margin-left:25px; width:600px;">

<img src="/images/cast-iron-skillet-49er-wide.png" alt="cast iron skillet 49er" title="if you don't behave, this guy will whack you on the head with his cast iron skillet" style="float:left; margin-right:15px;"/>

<p>
more from paul wheaton's glorious empire of web junk: 
<a href="http://www.richsoil.com/cast-iron.jsp">cast iron skillet</a>
<a href="http://www.richsoil.com/diatomaceous-earth.jsp">diatomaceous earth</a>
<a href="http://www.richsoil.com/rocket-stove-mass-heater.jsp">rocket mass heater</a>
<a href="http://www.richsoil.com/sepp-holzer/sepp-holzer-permaculture.jsp">sepp holzer</a>
<a href="http://www.richsoil.com/hugelkultur/">raised garden beds</a>
<a href="http://www.richsoil.com/raising-chickens.jsp">raising chickens</a>
<a href="http://www.richsoil.com/lawn-care.jsp">lawn care</a>
<a href="http://www.richsoil.com/CFL-fluorescent-light-bulbs.jsp">CFL</a>
<a href="http://www.richsoil.com/flea-control.jsp">flea control</a>
<a href="http://www.permies.com/missoula">missoula</a>
<a href="http://www.richsoil.com/electric-heat.jsp">heat</a>
<a href="http://www.permies.com/permaculture-forums">permaculture</a>
</p>

</div>

</td>

</tr>
</table>
</div>

</body>
</html>
